from sqlalchemy import Column, Integer, String, text, DECIMAL
from sqlalchemy.dialects.mysql import LONGTEXT

from models.base import Base, db


class AigcParagraphs(Base):
    __tablename__ = 'aigc_paragraphs'
    id = Column(Integer, primary_key=True, autoincrement=True)
    order_number = Column(String(30), nullable=False)
    paragraph_index = Column(Integer, nullable=False)
    content = Column(LONGTEXT, default='')
    type = Column(String(30), default='')
    ai = Column(Integer, default=0)
    rate = Column(DECIMAL, default=0)

    @property
    def show_content(self):
        return self.content.replace('\n','<br><p>')
